package com.maxmlr.concurrent.queue;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.SynchronousQueue;

/**
 * @ClassName SynchronousQueueTest
 * @Description 无容量队列
 * @Author maxiao
 * @Date 2020/2/27 下午2:25
 * @Version V1.0
 */
public class SynchronousQueueTest {
    static BlockingQueue<String> queue  = new SynchronousQueue();

    public static void main(String[] args) {
        System.out.println(111);
        new Thread(()->{
            try {
                String take = queue.take();
                System.out.println(take);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();

        try {
            queue.put("aaa");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(queue.size());
    }
}
